package com.wnhoo.smartfishtank.api;

import com.google.gson.Gson;
import com.wnhoo.smartfishtank.api.data.LM_DataNotice;
import com.wnhoo.smartfishtank.api.other.JSONUtil;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;

import java.io.IOException;

/**
 * Created by kevinwen on 2015/1/19.
 * Copyright (c) 2015/1/19.KevinWen. All rights reserved.
 */
public class LM_NoticeAPI {

    private final static String url = LM_BasicAPI.BASE_JSON_URL+"/plug/wnhoo/notice.json";
    public static LM_DataNotice checkeNotice( ) throws ClientProtocolException, IOException {

        HttpClient httpclient = new DefaultHttpClient();
        HttpPost post = new HttpPost(url);

        HttpResponse response = httpclient.execute(post);
        HttpEntity entity = response.getEntity();

        String json = JSONUtil.getJSONString(entity);
        //MyLog.TT("LM_NoticeAPI", json);
        Gson gson = new Gson();
        return gson.fromJson(json,LM_DataNotice.class);
    }

}
